<!DOCTYPE html><html lang="en"><head>
  <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  <meta content="width=device-width, initial-scale=1, shrink-to-fit=no" name="viewport">
  <meta content="CR" name="w3c-status">
  <title>HTML 5.1: 4. The elements of HTML</title>
  <link href="styles/styles-html.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href=styles.default.css>
  <meta content="Bikeshed 1.0.0" name="generator">

  <link href="styles/W3C-CR" rel="stylesheet" type="text/css">
 </head>
 <body class="h-entry">
  <div class="head">
   <header>
    <p data-fill-with="logo"><a href="http://www.w3.org/"><img alt="W3C" height="48" src="styles/logos/W3C" width="72"></a></p>
    <h1 class="p-name no-ref allcaps" id="title">HTML 5.1</h1>
    <h2 class="no-num no-toc no-ref heading settled" id="subtitle"><span class="content">W3C Candidate Recommendation, <time class="dt-updated" datetime="2016-06-21">21 June 2016</time></span></h2>
   </header>
   
   
   
   
  </div>
  
  
  
  
  
  <nav data-fill-with="table-of-contents" id="toc"><p class="prev_next">← <a href="dom.html#dom"><span class="secno">3</span> <span class="content">Semantics, structure, and APIs of HTML documents</span></a> — <a href="index.html#contents">Table of contents</a> — <a href="document-metadata.html#document-metadata"><span class="secno">4.2</span> <span class="content">Document metadata</span></a> →</p>
   <h2 class="no-num no-toc no-ref" id="contents">Table of Contents</h2>
   <ol class="toc" role="directory"><li>
     <a href="semantics.html#semantics"><span class="secno">4</span> <span class="content">The elements of HTML</span></a>
     <ol class="toc">
      <li>
       <a href="semantics.html#the-root-element"><span class="secno">4.1</span> <span class="content">The root element</span></a>
       <ol class="toc">
        <li><a href="semantics.html#the-html-element"><span class="secno">4.1.1</span> <span class="content">The <span><code>html</code></span> element</span></a>
       </li></ol>
      </li></ol>
    </li></ol>
  </nav><main><section><h2 class="heading settled" data-level="4" id="semantics"><span class="secno">4. </span><span class="content">The elements of HTML</span><a class="self-link" href="semantics.html#semantics"></a></h2><section>
     <h3 class="heading settled" data-level="4.1" id="the-root-element"><span class="secno">4.1. </span><span class="content">The root element</span><a class="self-link" href="semantics.html#the-root-element"></a></h3>
     <h4 class="heading settled" data-level="4.1.1" id="the-html-element"><span class="secno">4.1.1. </span><span class="content">The <dfn class="dfn-paneled" data-dfn-type="element" data-export="" id="elementdef-html"><code>html</code></dfn> element</span><a class="self-link" href="semantics.html#the-html-element"></a></h4>
     <dl class="element">
      <dt><a data-link-type="dfn" href="dom.html#categories" id="ref-for-categories-2">Categories</a>:
      </dt><dd>None.
      </dd><dt><a data-link-type="dfn" href="dom.html#contexts-in-which-this-element-can-be-used" id="ref-for-contexts-in-which-this-element-can-be-used-1">Contexts in which this element can be used</a>:
      </dt><dd>As the root element of a document.
      </dd><dd>Wherever a subdocument fragment is allowed in a compound document.
      </dd><dt><a data-link-type="dfn" href="dom.html#content-model" id="ref-for-content-model-4">Content model</a>:
      </dt><dd>A <code><a data-link-type="element" href="document-metadata.html#elementdef-head" id="ref-for-elementdef-head-12">head</a></code> element followed by a <code><a data-link-type="element" href="sections.html#elementdef-body" id="ref-for-elementdef-body-20">body</a></code> element.
      </dd><dt><a data-link-type="dfn" href="dom.html#tag-omission-in-text-html" id="ref-for-tag-omission-in-text-html-1">Tag omission in text/html</a>:
      </dt><dd> An <code><a data-link-type="element" href="semantics.html#elementdef-html" id="ref-for-elementdef-html-12">html</a></code> element’s <a data-link-type="dfn" href="syntax.html#start-tag" id="ref-for-start-tag-3">start tag</a> can be omitted if the first thing inside the <code><a data-link-type="element" href="semantics.html#elementdef-html" id="ref-for-elementdef-html-13">html</a></code> element is not a <a data-link-type="dfn" href="syntax.html#comment" id="ref-for-comment-1">comment</a>. 
      </dd><dd> An <code><a data-link-type="element" href="semantics.html#elementdef-html" id="ref-for-elementdef-html-14">html</a></code> element’s <a data-link-type="dfn" href="syntax.html#end-tag" id="ref-for-end-tag-4">end tag</a> can be omitted if the <code><a data-link-type="element" href="semantics.html#elementdef-html" id="ref-for-elementdef-html-15">html</a></code> element
      is not immediately followed by a <a data-link-type="dfn" href="syntax.html#comment" id="ref-for-comment-2">comment</a>. 
      </dd><dt><a data-link-type="dfn" href="dom.html#content-attribute" id="ref-for-content-attribute-2">Content attributes</a>:
      </dt><dd><a data-link-type="dfn" href="dom.html#global-attributes" id="ref-for-global-attributes-1">Global attributes</a>
      </dd><dt>Allowed <a href="dom.html#aria-role-attribute">ARIA role attribute</a> values:
      </dt><dd>None
      </dd><dt>Allowed <a href="dom.html#state-and-property-attributes">ARIA state and property attributes</a>:
      </dt><dd><a data-link-type="dfn" href="dom.html#global-aria--attributes" id="ref-for-global-aria--attributes-3">Global aria-* attributes</a>
      </dd><dt><a data-link-type="dfn" href="dom.html#dom-interface" id="ref-for-dom-interface-1">DOM interface</a>:
      </dt><dd>
<pre class="idl highlight def" data-highlight="webidl"><span class="kt">interface</span> <dfn class="nv dfn-paneled idl-code" data-dfn-for="HTMLHtmlElement" data-dfn-type="interface" data-export="" id="htmlhtmlelement-htmlhtmlelement">HTMLHtmlElement</dfn> : <a class="n" data-link-type="idl-name" href="dom.html#htmlelement-htmlelement" id="ref-for-htmlelement-htmlelement-11">HTMLElement</a> {};
</pre>
     </dd></dl>
     <p>The <code><a data-link-type="element" href="semantics.html#elementdef-html" id="ref-for-elementdef-html-16">html</a></code> element <a data-link-type="dfn" href="dom.html#represent" id="ref-for-represent-4">represents</a> the root of an HTML document.</p>
     <p>Authors are encouraged to specify a <code><a data-link-type="element-sub" href="dom.html#element-attrdef-global-lang" id="ref-for-element-attrdef-global-lang-24">lang</a></code> attribute on the root <code><a data-link-type="element" href="semantics.html#elementdef-html" id="ref-for-elementdef-html-17">html</a></code> element, giving
  the document’s language. This aids speech synthesis tools to determine what pronunciations to use,
  translation tools to determine what rules to use, and so forth.</p>
     <p class="note" role="note"> It is recommended to keep the usage of attributes and their values defined on the <code><a data-link-type="element" href="semantics.html#elementdef-html" id="ref-for-elementdef-html-18">html</a></code> element to a minimum to allow for proper detection of the <a data-link-type="dfn" href="document-metadata.html#character-encoding-declaration" id="ref-for-character-encoding-declaration-1">character encoding declaration</a> within the first 1024 bytes. </p>
     <div class="example" id="example-ea73cf5a">
      <a class="self-link" href="semantics.html#example-ea73cf5a"></a> The <code><a data-link-type="element" href="semantics.html#elementdef-html" id="ref-for-elementdef-html-19">html</a></code> element in the following example declares that the document’s language is
    English. 
<pre class="highlight"><span class="cp">&lt;!DOCTYPE html&gt;</span>
<span class="nt">&lt;html</span> <span class="na">lang=</span><span class="s">"en"</span><span class="nt">&gt;</span>
  <span class="nt">&lt;head&gt;</span>
    <span class="nt">&lt;title&gt;</span>Swapping Songs<span class="nt">&lt;/title&gt;</span>
  <span class="nt">&lt;/head&gt;</span>
  <span class="nt">&lt;body&gt;</span>
    <span class="nt">&lt;h1&gt;</span>Swapping Songs<span class="nt">&lt;/h1&gt;</span>
    <span class="nt">&lt;p&gt;</span>Tonight I swapped some of the songs I wrote with some friends, who
    gave me some of the songs they wrote. I love sharing my music.<span class="nt">&lt;/p&gt;</span>
  <span class="nt">&lt;/body&gt;</span>
<span class="nt">&lt;/html&gt;</span>
</pre>
     </div>
    </section></section></main>
  
<script src="js/fixup.js"></script>
  

<p class="prev_next">← <a href="dom.html#dom"><span class="secno">3</span> <span class="content">Semantics, structure, and APIs of HTML documents</span></a> — <a href="index.html#contents">Table of contents</a> — <a href="document-metadata.html#document-metadata"><span class="secno">4.2</span> <span class="content">Document metadata</span></a> →</p></body></html>
